<?php

namespace mpend\modules\activity\models;

use Yii;
use common\models\shop\ShopActivity;

/**
 * 精选活动商品列表
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class CareProductSearch extends \common\models\shop\ShopActivityProductGroup {

    /**
     * @var integer 分页请求大小
     */
    public $pagesize = 2;

    /**
     * @return Query
     */
    public function buildQuery() {
        $query = static::find()->alias('t')->andWhere([
            't.activity_id' => $this->activity_id,
        ]);
        $query->with('products');
        $query->innerJoinWith('activity a')->andWhere([
            'and',
            ['a.deleted_at' => 0],
            ['a.status' => ShopActivity::STATUS_ACTIVE],
        ]);
        //
        return $query;
    }

}
